1770B - Koxia and Permutation - CodeForces Solution


constructive algorithms *1000

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl '\n'
const int N = 1e6 + 9, MOD = 1000000007;
typedef long long ll;
using namespace std;
void solve()
{
    int n, m;
    cin >> n >> m;
    int r = n, l = 1;
    while (l < r)
    {
        cout << r << " " << l << " ";
        l++, r--;
    }
    if (n % 2)
        cout << l;
    cout << "\n";
}
int main(void)
{
    IO;
    int t = 1;
    cin >> t;
    while (t--)
        solve();
    return 0;
}


Comments

Submit
0 Comments
More Questions

952. Largest Component Size by Common Factor
212. Word Search II
174. Dungeon Game
127. Word Ladder
123. Best Time to Buy and Sell Stock III
85. Maximal Rectangle
84. Largest Rectangle in Histogram
60. Permutation Sequence
42. Trapping Rain Water
32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word